package com.example.mybatisplus.query;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.example.mybatisplus.pojo.Business;
import com.example.mybatisplus.pojo.Food;
import com.github.yulichang.query.MPJLambdaQueryWrapper;
import com.github.yulichang.query.MPJQueryWrapper;
import lombok.Data;


@Data
public class FoodQuery extends BaseQuery{

	private String foodName; //餐品名称搜索条件
	private Integer businessId; //商家编号

	/**
	 * select f.foodId, f.foodName, f.foodExplain, foodImg, foodPrice, f.businessId, f.remarks ,
	 *                b.businessName as 'business.businessName'
	 *         from t_food f left join t_business b on f.businessId=b.businessId
	 *         <if test="ew.sqlSegment!=null and ew.sqlSegment!=''">
	 *             where ${ew.sqlSegment}
	 *         </if>
	 *         order by foodId desc
	 * @return
	 */
	@Override
	public Wrapper getQueryWrapper() {
		QueryWrapper queryWrapper = new QueryWrapper();

		if (StringUtils.isNotEmpty(foodName)){
			queryWrapper.like("foodName",foodName);
		}
		if (businessId!=null && businessId!=0){
			queryWrapper.eq("f.businessId",businessId);
		}
		return queryWrapper;
	}
}
